feat: add claude md rules - #63
Conversation
… consolidating oversized test cases
…int-node into feature/WTI-787--add-claude-md-rules
1fc81a6
There was a problem hiding this comment.
suggestion: Since the rule itself doesn't distinguish the file it is being run on - should we just use the built in https://eslint.org/docs/latest/rules/max-lines rule instead (and target CLAUDE.md with it)?
There was a problem hiding this comment.
That's a good point, let me see if we can use that
There was a problem hiding this comment.
According to Claude:
Good question — I looked into this. The built-in max-lines won't work here: CLAUDE.md is linted with language: 'markdown/gfm' (otherwise ESLint parses the Markdown as JS and errors), and the built-in rule listens on Program:exit while the Markdown AST's root node is root. So it would silently never fire, and it also calls JS-only SourceCode APIs (getAllComments, etc.) that the Markdown language doesn't provide. That's why this custom rule hooks root(). The "doesn't distinguish the file" point is true but harmless since files: ['**/CLAUDE.md'] already scopes it.
There was a problem hiding this comment.
Yeah I ummed and arred about leaving a similar comment - I think it does need to be a unique rule but there's potentially a mismatch between max-lines and it specifically mentioning CLAUDE.md. We could use this for SKILL.md with a different threshold etc so maybe the wording being generic would help?
You'd know what file from the output.
Add CLAUDE.md linting rules
Summary of Changes 📋
max-linesrule to enforce line count limitsclaude-md.config.jswith dedicated ESLint configuration for linting CLAUDE.md filesindex.js(Node) andbrowser.js(Browser/React) ESLint configurationsmax-linesruledocs/adr/0001-lint-claude-md-with-eslint.md) documenting the decision to lint CLAUDE.md with ESLintexamples/claude-md-usage.mdwith usage documentation for the new linting rules@eslint/markdowndependency4.3.0-next.1Notes
This PR introduces a new ESLint plugin (
plugins/claude-md/) that enforces a maximum line count onCLAUDE.mdfiles, helping keep AI context files concise and maintainable. The plugin is automatically included in both the Node and Browser ESLint configurations exported by this package.